var a = 1;
document.onkeydown = function (event) {
    if (a == 1) {
        var e = event || window.event || arguments.callee.caller.arguments[0];
        if (e && e.keyCode == 13) { // 回车键登录
            login();
        }
    }
};

/*登录按钮*/
function login() {
    //   layer.alert("login");
    $.ajax({
        type: 'POST',
        asyn: false,
        url: "user/login",
        data: {
            userName: $("#username").val(),
            Password: $("#password").val()
        },
        dataType: 'JSON',
        success: function (data) {
            if (data == true) {
                location.href = "user/index";
            }
            else {
                //    alert("用户名,密码不匹配，请重新输入！");
                new TipBox({type: 'error', str: '用户名,密码不匹配，请重新输入!', hasBtn: true});
            }
        }
    });
}


function cancle() {
    $("#username").val("");
    $("#password").val("");
}